<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
    <!-- BEGIN HEAD -->
    <head>
    <include file="Public:meta" />
    <link rel="stylesheet" type="text/css" href="__TMPL__Public/plugins/bootstrap-fileupload/bootstrap-fileupload.css" />
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
<include file="Public:header" />
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <include file="Public:sidebar" />
    <!-- BEGIN PAGE -->
    <div class="page-content">
        <!-- BEGIN PAGE CONTAINER-->
        <div class="container-fluid">
            <!-- BEGIN PAGE HEADER-->
            <div class="row-fluid">
                <!-- begin BCN -->
                <div class="row-fluid">
                    <div class="span12"><ul class="breadcrumb"><li><i class="icon-home"></i><a onfocus="blurLink(this);" href="{:U('Index/index')}">首页</a>&nbsp;<span class="icon-angle-right"></span>&nbsp;</li><li><a onfocus="blurLink(this);" href="{:U(CONTROLLER_NAME . '/index', 'kept=1')}">{$ParentPageName|default="未命名"}</a>&nbsp;<span class="icon-angle-right"></span>&nbsp;</li><li>{$PageName|default="未命名"}</li></ul></div>
                </div>
                <!-- end BCN -->
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN PAGE CONTENT-->
            <div class="row-fluid profile">
                <div class="span12">
                    <form action="{:U('Index/config')}" class="form-horizontal" enctype="multipart/form-data" method="post">
                        <!--BEGIN TABS-->
                        <div class="tabbable tabbable-custom tabbable-full-width">
                            <ul class="nav nav-tabs">
                                <li class="active"><a href="#tab_1_1" data-toggle="tab">站点信息</a></li>
                                <!-- <li class=""><a href="#tab_1_2" data-toggle="tab">短信设置</a></li> -->
                                <!-- <li class=""><a href="#tab_1_2" data-toggle="tab">邮件设置</a></li> -->
                                <li class=""><a href="#tab_1_3" data-toggle="tab">其他设置</a></li>
                                <li class=""><a href="#tab_1_4" data-toggle="tab">小程序设置</a></li>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane row-fluid active" id="tab_1_1">
                                    <div class="row-fluid">
                                        <div class="span12">
                                            <div class="portlet">
                                                <div class="portlet-title">
                                                    <div class="caption"><i class="icon-globe"></i>站点信息</div>
                                                </div>
                                                <div class="portlet-body">
                                                    <div class="row-fluid">
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <label class="control-label">系统名称</label>
                                                                <div class="controls"><input type="text" class="span12 m-wrap" name="sitename" value="{$Config.sitename}" /></div>
                                                            </div>
                                                        </div>
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <label class="control-label">技术支持</label>
                                                                <div class="controls"><input type="text" class="span12 m-wrap" name="copyright" value="{$Config.copyright}" /></div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row_fluid">
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <label class="control-label">新人礼包</label>
                                                                <div class="controls">
                                                                    <div class="span6 fileupload <notempty name="Config[adv]">fileupload-exists<else />fileupload-new</notempty>" data-provides="fileupload">
                                                                        <div class="input-append">
                                                                            <div class="uneditable-input">
                                                                                <i class="icon-file fileupload-exists"></i> 
                                                                                <span class="fileupload-filename">
                                                                                    <notempty name="Config[adv]">
                                                                                        {$Config[adv]}
                                                                                    </notempty>
                                                                                </span>
                                                                            </div>
                                                                            <span class="btn btn-file">
                                                                                <span class="fileupload-new">选择图片</span>
                                                                                <span class="fileupload-exists">更改图片</span>
                                                                                <input type="file" class="default" name="adv" />
                                                                            </span>
                                                                        </div>
                                                                        <div class="fileupload-preview thumbnail">
                                                                            <notempty name="Config[adv]">
                                                                                <img src="Uploads/{$Config.adv}"/>
                                                                            </notempty>
                                                                        </div>
                                                                        <div class="btn-box">
                                                                            <notempty name="Config[adv]">
                                                                                <a class="btn green-stripe mini image_view fileupload-change" href="#show_pic" data-toggle="modal" data-width="auto" rel="Uploads/{$Config.adv}">预览<i class="icon-eye-open"></i></a>
                                                                            </notempty>
                                                                            <div class="clear"></div>
                                                                            <a class="btn red-stripe mini image_delete fileupload-exists" href="javascript:void(0);" data-dismiss="fileupload">删除<i class="icon-trash"></i></a>
                                                                            <input type="hidden" value="0" name="delete_adv" class="fileupload-delete" />
                                                                        </div>
                                                                    </div>
                                                                    <span class="help-inline">建议上传尺寸:710*125</span>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane row-fluid" id="tab_1_3">
                                    <div class="row-fluid">
                                        <div class="span12">
                                            <div class="portlet">
                                                <div class="portlet-title">
                                                    <div class="caption"><i class="icon-comments"></i>附件</div>
                                                </div>
                                                <div class="portlet-body">
                                                    <!-- <div class="row-fluid">
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <label class="control-label">逻辑删除</label>
                                                                <div class="controls">
                                                                    <div class="success-toggle-button">
                                                                        <input type="checkbox" class="toggle" name="is_del" value="1" <if condition="$Config['is_del'] eq 1">checked="checked"</if> />
                                                                    </div>
                                                                    <span class="help-inline">是否开启数据逻辑删除，系统默认物理删除</span>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div> -->
                                                    <!-- <div class="row-fluid">
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <label class="control-label">新人券金额</label>
                                                                <div class="controls"><input type="text" class="span6 m-wrap" name="money" value="{$Config.money}" /><span class="help-inline">金额为正整数</span></div>
                                                            </div>
                                                        </div>
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <label class="control-label">时效期</label>
                                                                <div class="controls"><input type="text" class="span6 m-wrap" name="expired" value="{$Config.expired}" /><span class="help-inline">时效期为正整数,单位为天</span></div>
                                                            </div>
                                                        </div>
                                                    </div> -->
                                                    <div class="row-fluid">
                                                        <div class="span6">
                                                            <div class="control-group">
                                                                <label class="control-label">订单号前缀</label>
                                                                <div class="controls"><input type="text" class="span6 m-wrap" name="order_prefix" value="{$Config.order_prefix}" /></div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane row-fluid" id="tab_1_4">
                                    <div class="portlet-title">
                                        <div class="caption"><i class="icon-envelope-alt"></i>微信接口</div>
                               	    </div>
                                    <div class="row-fluid">
                                        <div class="span6">
                                            <div class="control-group">
                                                <label class="control-label">APPID</label>
                                                <div class="controls">
                                                    <input type="text" class="span6 m-wrap" name="appid" value="{$Config.appid}" />
                                                    <span class="help-inline">小程序appid</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="span6">
                                            <div class="control-group">
                                            <label class="control-label">APPSECRET</label>
                                                <div class="controls">
                                                <input type="text" class="span6 m-wrap" name="appsecret" value="{$Config.appsecret}" />
                                                <span class="help-inline">小程序secret</span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row-fluid">
                                        <div class="span6">
                                            <div class="control-group">
                                                <label class="control-label">MCHID</label>
                                                <div class="controls">
                                                    <input type="text" class="span6 m-wrap" name="mchid" value="{$Config.mchid}" />
                                                    <span class="help-inline">商户号</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="span6">
                                            <div class="control-group">
                                                <label class="control-label">KEY</label>
                                                <div class="controls">
                                                    <input type="text" class="span6 m-wrap" name="key" value="{$Config.key}" />
                                                	<span class="help-inline">商户支付的密钥(微信商户后台设置的32位字符串)</span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--END TABS-->
                        <div class="form-button">
                            <button type="submit" class="btn blue">保存数据 <i class="icon-save"></i></button>
                        </div>
                    </form>
                </div>
            </div>
            <!-- END PAGE CONTENT-->
        </div>
        <!-- END PAGE CONTAINER-->
    </div>
    <!-- END PAGE -->
</div>
<!-- END CONTAINER -->

<div id="email_setting" class="modal hide fade" tabindex="-1" data-backdrop="static" data-keyboard="false" data-width="760"></div>

<include file="Public:footer" />

<script type="text/javascript" src="__TMPL__Public/plugins/bootstrap-fileupload/bootstrap-fileupload.js"></script>
<script type="text/javascript" src="__TMPL__Public/scripts/laydate/laydate.js"></script>
<script type="text/javascript">
    function checkServer(){
        var is_remote = $('span[class=checked]').find('input[name=is_remote]').val();
        if(is_remote!=0){
            $('.is_remote').show();
        }else{
            $('.is_remote').hide();
        }
    }
    $(function(){
        checkServer();
        $('input[name=is_remote]').live('click',function(){
            checkServer();
        })
        /*时间选择器*/
        laydate.render({
            elem: '#time'
            ,type: 'time'
            ,format:'HH:mm'
        });
    })
    jQuery(document).ready(function(){
        $('#testSmsButton').click(function(){
            var _this = $('#testSmsButton');
            var phone = $('#sms_testphone').val();
            var content = $('#sms_testcontent').val();
            if(phone==''||content==''){
                $('.testSms .warning-default').hide();
                $('.testSms .warning-change').html('请按要求将以上信息填写完整').css('color','red');
                $('.testSms .warning-change').show();
            }else{
                var sendUrl = _this.attr('data-url');
                $.ajax({
                    type: "POST",
                    url: sendUrl,
                    data: {'ajax':'testSms','phone':phone,'content':content},
                    dataType:"json",
                    success: function(data){
                        if(data.status==1){
                            var tmp = '发送成功！请查看'+phone+'确认短信...';
                            $('.testSms .warning-default').hide();
                            $('.testSms .warning-change').html(tmp).css('color','green');
                            $('.testSms .warning-change').show();
                        }else{
                            $('.testSms .warning-default').hide();
                            $('.testSms .warning-change').html('短信发送失败，请检查短信配置').css('color','red');
                            $('.testSms .warning-change').show();
                        }
                        _this.attr("disabled", false);
                        _this.val("点击发送"); 
                    },
                    beforeSend: function(){
                        var tmp = '正在发送给'+phone+'...';
                        $('.testSms .warning-default').hide();
                        $('.testSms .warning-change').html(tmp).css('color','green');
                        $('.testSms .warning-change').show();
                        _this.attr("disabled", true);
                        _this.val("正在发送..."); 
                    }
                });
            }
        });
        $('#testEmailButton').click(function(){
            var _this = $('#testEmailButton');
            var email = $('#smtp_testemail').val();
            var content = $('#smtp_testcontent').val();
            if(email==''||content==''){
                $('.testEmail .warning-default').hide();
                $('.testEmail .warning-change').html('请按要求将以上信息填写完整').css('color','red');
                $('.testEmail .warning-change').show();
            }else{
                var sendUrl = _this.attr('data-url');
                $.ajax({
                    type: "POST",
                    url: sendUrl,
                    data: {'ajax':'testEmail','email':email,'content':content},
                    dataType:"json",
                    success: function(data){
                        if(data.status==1){
                            var tmp = '发送成功！请进入'+email+'确认邮件...';
                            $('.testEmail .warning-default').hide();
                            $('.testEmail .warning-change').html(tmp).css('color','green');
                            $('.testEmail .warning-change').show();
                        }else{
                            $('.testEmail .warning-default').hide();
                            $('.testEmail .warning-change').html('邮件发送失败，请检查邮件服务器配置').css('color','red');
                            $('.testEmail .warning-change').show();
                        }
                        _this.attr("disabled", false);
                        _this.val("点击发送"); 
                    },
                    beforeSend: function(){
                        var tmp = '正在发送给'+email+'...';
                        $('.testEmail .warning-default').hide();
                        $('.testEmail .warning-change').html(tmp).css('color','green');
                        $('.testEmail .warning-change').show();
                        _this.attr("disabled", true);
                        _this.val("正在发送..."); 
                    }
                });
            }
        });
                                                    
        //邮件模板设置
        $('.email_setting').on('click', function(){
            // create the backdrop and wait for next modal to be triggered
            $('body').modalmanager('loading');
            $.post($(this).attr('ajax'), {ajax:'email_template_show'}, function(data){
                $('#email_setting').html(data).modal();
            });
            return false;
        });
        //ajax保存邮件模板
        $('#email_setting').on('click', '.email_save', function(){
            var formObj = $(this).parents('#email_setting').find('form');
            $.post(formObj.attr('action'), 'ajax=email_template_save&'+formObj.serialize(), function(data){
                $('#email_setting').modal('toggle');
            });
        });
    });
</script>
</body>
<!-- END BODY -->
</html>